package com.yyplatform.admin.platform.init.data;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.yyplatform.admin.platform.notice.controller.SysNoticeController;
import com.yyplatform.admin.platform.notice.controller.SysNoticeUserController;
import com.yyplatform.admin.platform.role.model.entity.SysMenuEntity;
import com.yyplatform.admin.platform.role.model.enums.MenuTypeEnum;
import com.yyplatform.admin.platform.role.repository.SysMenuRepository;
import com.yyplatform.admin.platform.role.service.SysMenuService;

/**
 * @author sleepforests@163.com
 * <p>
 * Created on 2024/11/16 20:42
 */

public class InitMenuData5Notice {

    private SysMenuRepository sysMenuRepository;

    private SysMenuService sysMenuService;

    public InitMenuData5Notice(SysMenuRepository sysMenuRepository1, SysMenuService sysMenuService1) {
        sysMenuRepository = sysMenuRepository1;
        sysMenuService = sysMenuService1;
    }

    public void init() {

        String name = "通知消息";

        SysMenuEntity menu = new SysMenuEntity();
        menu.setAlwaysShow(true);
        menu.setComponent("Layout");
        menu.setEnabled(true);
        menu.setIcon("el-icon-BellFilled");
        menu.setKeepAlive(true);
        menu.setName(name);
        menu.setOrderNum(100);
        menu.setParams(Collections.emptyList());
        menu.setPermissions("");
        menu.setPid(0L);
        menu.setRedirect("");
        menu.setRemark("");
        menu.setRouteName("");
        menu.setRoutePath("/notice");
        menu.setVisible(true);

        menu.setMenuType(MenuTypeEnum.MENU_TYPE_FOLDER.getValue());

        sysMenuRepository.save(menu);


        test_init_我的通知(menu);
        test_init_通知管理(menu);
    }


    //    @Test
    public void test_init_我的通知(SysMenuEntity rootEntity) {

        long id = 0;


        SysMenuEntity menu = new SysMenuEntity();
        menu.setAlwaysShow(false);
        menu.setComponent("platform/noticeUser/index");
        menu.setEnabled(true);
        menu.setIcon("table");
        menu.setKeepAlive(true);
        menu.setName("我的通知");
        menu.setOrderNum(100);
        menu.setParams(Collections.emptyList());
        menu.setPermissions("sys:noticeUser:query");
        menu.setPid(rootEntity.getId());
        menu.setRedirect("");
        menu.setRemark("");
        menu.setRouteName("NoticeUser");
        menu.setRoutePath("platform/noticeUser/index");
        menu.setVisible(true);

        menu.setMenuType(MenuTypeEnum.MENU_TYPE_MENU.getValue());

        sysMenuRepository.save(menu);

        id = menu.getId();


        List<String> list2 = new ArrayList<>();
        list2.add(SysNoticeUserController.class.getName());
        sysMenuService.saveBatchByControllerName(id, list2);

    }


    public void test_init_通知管理(SysMenuEntity root) {


        SysMenuEntity menu = new SysMenuEntity();
        menu.setAlwaysShow(false);
        menu.setComponent("platform/notice/index");
        menu.setEnabled(true);
        menu.setIcon("table");
        menu.setKeepAlive(true);
        menu.setName("通知管理");
        menu.setOrderNum(100);
        menu.setParams(Collections.emptyList());
        menu.setPermissions("sys:notice:query");
        menu.setPid(root.getId());
        menu.setRedirect("");
        menu.setRemark("");
        menu.setRouteName("Notice");
        menu.setRoutePath("platform/notice/index");
        menu.setVisible(true);

        menu.setMenuType(MenuTypeEnum.MENU_TYPE_MENU.getValue());

        sysMenuRepository.save(menu);


        List<String> list2 = new ArrayList<>();
        list2.add(SysNoticeController.class.getName());
        sysMenuService.saveBatchByControllerName(menu.getId(), list2);

    }

}



